using UnityEditor;
using UnityEngine;

namespace Yoozoo.Art.Editor
{
    [CustomEditor(typeof(MeshCombineHost))]
    public class MeshCombineHostEditor : UnityEditor.Editor
    {
        private MeshCombineHost _target;

        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            _target = target as MeshCombineHost;
            if (_target == null)
                return;
            if (_target.Prefabs == null)
                return;

            if (GUILayout.Button("合并Mesh"))
            {
                var prefabs = new GameObject[_target.Prefabs.Length +1];
                prefabs[0] = _target.gameObject;
                for (int i = 0; i < _target.Prefabs.Length; i++)
                    prefabs[i + 1] = _target.Prefabs[i];
                
                SkinningMeshCombine.Execute(prefabs);
            }
        }
    }
}
